package me.itsoo.artemis.framework.ioc.context.event;

import me.itsoo.artemis.framework.core.eventbus.Event;
import me.itsoo.artemis.framework.ioc.context.ApplicationContext;
import me.itsoo.artemis.framework.ioc.lang.Bean;

/**
 * CustomRefreshedContextEventListener
 *
 * @author zxy
 * @version 0.0.1
 * @since 2023/6/14
 */
@Bean
public class CustomRefreshedContextEventListener implements ApplicationEventSubscriber {

    @Override
    public void listen(Event<ApplicationEvent> event) {
        ApplicationEvent source = event.getSource();
        if (source instanceof ApplicationRefreshEvent) {
            ApplicationContext applicationContext = source.getApplicationContext();
            boolean containsBarBean = applicationContext.containsBean("barBean");
            System.out.println("==> 自定义上下文刷新监听实现 has 'barBean'=" + containsBarBean);
        }
    }
}
